package pattern.singleton.hungry;

/**
 * 饿汉式静态单例
 * @author: jxj
 * @create: 2019-04-22
 **/
public class HungryStaticSingleton {
    //类元素加载顺序
    //1. 先静态后动态
    //2. 先属性后方法
    //3. 先上后下
    private static final HungryStaticSingleton hungrySingleton;
    static {
        hungrySingleton=new HungryStaticSingleton();
    }
    //构造函数设置为私有
    private HungryStaticSingleton(){}

    public static HungryStaticSingleton getInstance(){
        return hungrySingleton;
    }
}
